<?php

class Modelos extends Model {

	
	var $modelos = array();

 
    function Modelos()
    {
        // Call the Model constructor
        parent::Model();
    }
	

	function guardarArray(){
		
		$this->cargarModelosAdmin();
	
		
		$info = array();
		$info['tipo'] = 'Administrador';
		//$info['tipo'] = 'Visitante';
		$info['privilegios'] = serialize($this->modelos);
		
		// Diego usa:1
		// Javi usa: 55
		// Seba usa: 55
		
		//$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '1') );
	
	}
	
	function actulaizarPerfiles(){
		
		// Perfil Administrador
		$this->cargarModelosAdmin();
		
		$permisos = $this->modelos;
		
		$info = array();
		$info['tipo'] = 'Administrador';
		$info['privilegios'] = serialize($permisos);
				
		$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '1') );


		
		
		
		
	}
	
	
	function obtenerArray($idTipoUsuario){
		
		// no comenten nada, solo agreguen el idtipodeusuario que quieren actualizar. ( notar que ahora se usa update )
		// cierren y abran sesion y listo. ( ademas de agregar el modelo que querian agregar, obvio )
		//$this->guardarArray();
		$this->actulaizarPerfiles();
		
		
		$this->db->from('tipodeusuario');
		$this->db->where('idtipodeusuario',$idTipoUsuario);
		$query = $this->db->get();
		$arraydatos=array();
		foreach ($query->result() as $fila)
		{
			//echo $fila->idtipodeusuario;
			//echo $fila->tipo;
			$arraydatos['privilegios'] = unserialize($fila->privilegios);
			$arraydatos['tipodeusuario'] = $fila->tipo;
			/*echo '<PRE>';
			print_r($arraydatos);
			echo '</PRE>';
			exit(0);*/
		}
		return $arraydatos;
	}
	

	
	function cargarModelosAdmin(){
	
		$this->modelos = array();
	
		$this->modelos["conquer"] = array("realname" => "conquer",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["comanda"] = array("realname" => "comanda",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["estadodepto"] = array("realname" => "estadodepto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "0"
		);

		$this->modelos["estadocomanda"] = array("realname" => "estadocomanda",
			"ver" => "1",
			"agregar" => "0",
			"modificar" => "0",
			"eliminar" => "0"
		);

		$this->modelos["estadocivil"] = array("realname" => "estadocivil",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["formadepago"] = array("realname" => "formadepago",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "0"
		);

		$this->modelos["alarma"] = array("realname" => "alarma",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["departamento"] = array("realname" => "departamento",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["factura"] = array("realname" => "factura",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["mantenimiento"] = array("realname" => "mantenimiento",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["movimientocaja"] = array("realname" => "movimientocaja",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["pasajero"] = array("realname" => "pasajero",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["pasajeroxdepto"] = array("realname" => "pasajeroxdepto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["semana"] = array("realname" => "semana",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["tipodeusuario"] = array("realname" => "tipodeusuario",
			"ver" => "1",
			"agregar" => "0",
			"modificar" => "0",
			"eliminar" => "0"
		);

		$this->modelos["tipodoc"] = array("realname" => "tipodoc",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "0"
		);

		$this->modelos["usuario"] = array("realname" => "usuario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["tipomov"] = array("realname" => "tipomov",
			"ver" => "1",
			"agregar" => "0",
			"modificar" => "0",
			"eliminar" => "0"
		);


	}
	

	
	
}

?>
